package com.ruoyi.web.controller.control;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.control.dto.WaterDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.control.domain.CentralpumphouseHistory;
import com.ruoyi.control.service.ICentralpumphouseHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 中央水泵房Controller
 *
 * @author ruoyi
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/control/centrHistory")
public class CentralpumphouseHistoryController extends BaseController
{
    @Autowired
    private ICentralpumphouseHistoryService centralpumphouseHistoryService;

    /**
     * 查询中央水泵房列表
     */
    @PreAuthorize("@ss.hasPermi('control:centrHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(CentralpumphouseHistory centralpumphouseHistory)
    {
        startPage();
        System.out.println("1115" + centralpumphouseHistory.getUpdateTime());
        List<CentralpumphouseHistory> list = centralpumphouseHistoryService.selectCentralpumphouseHistoryList(centralpumphouseHistory);
        return getDataTable(list);
    }

    /**
     * 导出中央水泵房列表
     */
    @PreAuthorize("@ss.hasPermi('control:centrHistory:export')")
    @Log(title = "中央水泵房", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CentralpumphouseHistory centralpumphouseHistory)
    {
        List<CentralpumphouseHistory> list = centralpumphouseHistoryService.selectCentralpumphouseHistoryList(centralpumphouseHistory);
        ExcelUtil<CentralpumphouseHistory> util = new ExcelUtil<CentralpumphouseHistory>(CentralpumphouseHistory.class);
        util.exportExcel(response, list, "中央水泵房数据");
    }

    /**
     * 获取中央水泵房详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:centrHistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(centralpumphouseHistoryService.selectCentralpumphouseHistoryById(id));
    }
    /**
     * 获取中央水泵房详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:centrHistory:query')")
    @GetMapping(value = "/ByTagName/{tagName}")
    public AjaxResult ByTagName(@PathVariable("tagName") String tagName)
    {
        Integer[] arr=centralpumphouseHistoryService.selectByTagName(tagName);
        return success(arr);
    }
    /**
     * 新增中央水泵房
     */
    @PreAuthorize("@ss.hasPermi('control:centrHistory:add')")
    @Log(title = "中央水泵房", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CentralpumphouseHistory centralpumphouseHistory)
    {
        return toAjax(centralpumphouseHistoryService.insertCentralpumphouseHistory(centralpumphouseHistory));
    }

    /**
     * 修改中央水泵房
     */
    @PreAuthorize("@ss.hasPermi('control:centrHistory:edit')")
    @Log(title = "中央水泵房", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CentralpumphouseHistory centralpumphouseHistory)
    {
        return toAjax(centralpumphouseHistoryService.updateCentralpumphouseHistory(centralpumphouseHistory));
    }

    /**
     * 删除中央水泵房
     */
    @PreAuthorize("@ss.hasPermi('control:centrHistory:remove')")
    @Log(title = "中央水泵房", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(centralpumphouseHistoryService.deleteCentralpumphouseHistoryByIds(ids));
    }

    /**
     * 中央水泵房故障次数  1天  排水阀故障次数
     */
    @GetMapping("/getWaterTotal")
    public int getWaterTotal()
    {
        int total = centralpumphouseHistoryService.getWaterTotal();
        return total;
    }

    /**
     *  7天  排水阀故障次数
     */
    @GetMapping("/getWeekWaterTotal")
    public List getWeekWaterTotal()
    {
        List<String> list = centralpumphouseHistoryService.getWeekWaterTotal();
        return list;
    }
}
